﻿//
// Created by work on 24-6-6.
//

#ifndef IOT_PLAT_CRTMODELYCINFO_H
#define IOT_PLAT_CRTMODELYCINFO_H

#include "CRtModelSigBase.h"



class CRtModelYcInfo : public CRtModelSigBase{
public:

    float base;
    float coef;
    bool en_alarm;
    float alarm_up_limit;
    float alarm_down_limit;
    QString alarm_up_limit_desc;
    QString alarm_down_limit_desc;
    int alarm_time_count;

    enum EModelYcCol {
        EBase = 7,
        ECoef,
        EEn_alarm,
        EAlarm_up_limit,
        EAlarm_down_limit,
        EAlarm_up_limit_desc,
        EAlarm_down_limit_desc,
        EAlarm_time_count
    };

    static std::map<CRtModelYcInfo::EModelYcCol, QString> rtModelYcColToStringMap;
    static std::map<CRtModelYcInfo::EModelYcCol, QString> ycColFieldsNameMap;
    static std::map<CRtModelYcInfo::EModelYcCol, CValue::EValueType> rtYcDataTypeByField;

    explicit CRtModelYcInfo(QObject *parent = nullptr);
public:
    virtual QString getFieldNameByCol(int col)override;

    virtual QVariant getFieldValueByFielddName(const QString& name)override;

    virtual void setFieldValueByCol(int col, const QVariant& value)override;

    virtual QJsonObject toJson()override;

    virtual void fromJson(const QJsonObject& json)override;

    virtual QSharedPointer<IModel> createEmpty()override;

    virtual bool sync(bool dir = true) override;
};

#define YC_ENUM                     CRtModelYcInfo::EModelYcCol
#define ycFieldName(type)           CRtModelYcInfo::rtModelYcColToStringMap.find(type)->second
#define ycColFieldName(type)        CRtModelYcInfo::ycColFieldsNameMap.find(type)->second
#define ycDataTypeByField(type)     CRtModelYcInfo::rtYcDataTypeByField.find(type)->second
#define YC_COL_SIZE                 (SIGBASE_COL_SIZE + rtModelYcColToStringMap.size())


#endif //IOT_PLAT_CRTMODELYCINFO_H
